package com.bw.services.device.model

import android.util.Log
import com.bw.common.http.NetUtils
import javax.inject.Inject

class DeviceRepo@Inject constructor(val apiServer: DeviceApiServer) {
    suspend fun getDevice(): DeviceEntity?{
        val result = NetUtils.httpRequest { apiServer.getDevice()}
        if(result.code==200){
            return  result.data
        }
        return  null
    }
    suspend fun AddDevice(data:AddDeviceBody): AddDeviceBody?{
        try {
            val result = NetUtils.httpRequest { apiServer.AddDevice(data) }
            Log.d("===", "code: ${result.code}")
            if(result.code==200){
                return  result.data
            }
        } catch (e: Exception) {
            Log.e("AddDevice", "网络请求异常", e)
        }
        return  null
    }
}